package com.zhs.rabbitmq.pubsub;

import com.zhs.rabbitmq.utils.RabbitConstant;
import com.zhs.rabbitmq.utils.RabbitUtils;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

/**
 * @author zhenghuisheng
 * 发布者发布消息
 */
public class WeatherBureau {

    public static void main(String[] args) throws Exception {
        //获取TCP长连接
        Connection connection = RabbitUtils.getConnection();
        //键盘手动输入信息
        String input = new BufferedReader(new InputStreamReader(System.in)).readLine();
        //通过连接获取通道
        Channel channel = connection.createChannel();
        //第一个参数交换机名字   其他参数和之前的一样
        channel.basicPublish(RabbitConstant.EXCHANGE_WEATHER,"" , null , input.getBytes());

        channel.close();
        connection.close();
    }
}
